package com.yubest.gen;

import com.yubest.gen.util.KeyUtil;
import com.yubest.tool.MyLicenseCreator;
import com.yubest.tool.bean.LicenseCreatorParam;

import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Files;

/**
 * @Author hweiyu
 * @Description
 * @Date 2022/6/15 14:47
 */
public class MainApp {

    public static void main(String[] args) {
        try {
            //生成公私钥对
            String subject = "mySubject";
            String pubPwd = "a123456";
            String priPwd = "a123457";
            KeyUtil.createKey(subject, pubPwd, priPwd);

            //读取客户端设备信息
            File device = new File("device.json");
            String json = Files.readAllLines(device.toPath(), Charset.forName("UTF-8")).get(0);

            //生成license
            LicenseCreatorParam param = new LicenseCreatorParam()
                    .setSubject(subject)
                    .setPubPass(pubPwd)
                    .setPriPass(priPwd)
                    .setDeviceInfo(json);
            new MyLicenseCreator()
                    .setCreatorParam(param)
                    .execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
